#include<bits/stdc++.h>
using namespace std;
void bag_erwei(){
    vector<int> weight={1,3,4};
    vector<int> value={15,20,30};
    int bagWeight=4;

    //二维数组
    vector<vector<int>> dp(weight.size(),vector<int>(bagWeight+1,0));

    //初始化
    for(int j=weight[0];j<=bagWeight;j++)
        dp[0][j]=value[0];
    for(int i=1;i<weight.size();i++){//遍历物品
        for(int j=0;j<=bagWeight;j++){//遍历背包容量(从小到大)
            if(j<weight[i]) dp[i][j]=dp[i-1][j];
            else dp[i][j]=max(dp[i-1][j],dp[i-1][j-weight[i]]+value[i]);
        }
    }
    cout<<dp[weight.size()-1][bagWeight]<<endl;
}

int main(){
    bag_erwei();
}